/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package crm.salesOrderProcessing.entity;

import commonInfrastructure.accountManagement.entity.SalesmanEntity;
import crm.clientManagement.entity.CompanyEntity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import scm.inventoryControl.entity.ProductBatchRecordEntity;

/**
 *
 * @author ReinForceII
 */
@Entity
public class SalesOrderEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private boolean skipConfirm;
    
    private int statusId;
    private double totalAmount;
    

    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dateConfirmed;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dateCreated;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dateLastModified;
    
    @ManyToOne
    private SalesmanEntity processedBy;
    @ManyToOne
    private SalesmanEntity confirmedBy;
    @OneToMany(cascade = {CascadeType.ALL})
    private List<LineItemEntity> salesOrderLineItems;
    @ManyToOne
    private CompanyEntity customer;
    @OneToOne
    private SalesQuotationEntity salesQuotation;
    @ManyToOne
    private SalesmanEntity largeOrderConfirmedBy;
//    @OneToMany(mappedBy="salesOrder",cascade = {CascadeType.ALL})
//    private List<ProductBatchRecordEntity> productBatchRecords;
    
    
    @OneToMany(cascade={CascadeType.ALL}, mappedBy="parentSalesOrder")
    private List<DeliveryOrderEntity> childDeliveryOrders;
    
    private boolean cashInAdvance;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SalesOrderEntity)) {
            return false;
        }
        SalesOrderEntity other = (SalesOrderEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "salesOrderProcessing.entity.PurchaseOrderEntity[ id=" + id + " ]";
    }

    /**
     * @return the salesOrderLineItems
     */
    public List<LineItemEntity> getSalesOrderLineItems() {
        return salesOrderLineItems;
    }



    /**
     * @return the isSkipConfirm
     */
    public boolean isSkipConfirm() {
        return skipConfirm;
    }

    /**
     * @param isSkipConfirm the isSkipConfirm to set
     */
    public void setSkipConfirm(boolean skipConfirm) {
        this.skipConfirm = skipConfirm;
    }

    /**
     * @return the processedBy
     */
    public SalesmanEntity getProcessedBy() {
        return processedBy;
    }

    /**
     * @param processedBy the processedBy to set
     */
    public void setProcessedBy(SalesmanEntity processedBy) {
        this.processedBy = processedBy;
    }

    /**
     * @return the confirmedBy
     */
    public SalesmanEntity getConfirmedBy() {
        return confirmedBy;
    }

    /**
     * @param confirmedBy the confirmedBy to set
     */
    public void setConfirmedBy(SalesmanEntity confirmedBy) {
        this.confirmedBy = confirmedBy;
    }

    /**
     * @return the dateCreated
     */
    public Date getDateCreated() {
        return dateCreated;
    }

    /**
     * @param dateCreated the dateCreated to set
     */
    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }


    /**
     * @return the customer
     */
    public CompanyEntity getCustomer() {
        return customer;
    }

    /**
     * @param customer the customer to set
     */
    public void setCustomer(CompanyEntity customer) {
        this.customer = customer;
    }

    /**
     * @return the salesQuotation
     */
    public SalesQuotationEntity getSalesQuotation() {
        return salesQuotation;
    }

    /**
     * @param salesQuotation the salesQuotation to set
     */
    public void setSalesQuotation(SalesQuotationEntity salesQuotation) {
        this.salesQuotation = salesQuotation;
    }

    /**
     * @return the totalAmount
     */
    public double getTotalAmount() {
        return totalAmount;
    }

    /**
     * @param totalAmount the totalAmount to set
     */
    public void setTotalAmount(double totalAmount) {
        this.totalAmount = totalAmount;
    }

    /**
     * @param salesOrderLineItems the salesOrderLineItems to set
     */
    public void setSalesOrderLineItems(List<LineItemEntity> salesOrderLineItems) {
        this.salesOrderLineItems = salesOrderLineItems;
    }

    /**
     * @return the dateConfirmed
     */
    public Date getDateConfirmed() {
        return dateConfirmed;
    }

    /**
     * @param dateConfirmed the dateConfirmed to set
     */
    public void setDateConfirmed(Date dateConfirmed) {
        this.dateConfirmed = dateConfirmed;
    }

    /**
     * @return the largeOrderConfirmedBy
     */
    public SalesmanEntity getLargeOrderConfirmedBy() {
        return largeOrderConfirmedBy;
    }

    /**
     * @param largeOrderConfirmedBy the largeOrderConfirmedBy to set
     */
    public void setLargeOrderConfirmedBy(SalesmanEntity largeOrderConfirmedBy) {
        this.largeOrderConfirmedBy = largeOrderConfirmedBy;
    }

    /**
     * @return the dateLastModified
     */
    public Date getDateLastModified() {
        return dateLastModified;
    }

    /**
     * @param dateLastModified the dateLastModified to set
     */
    public void setDateLastModified(Date dateLastModified) {
        this.dateLastModified = dateLastModified;
    }

    /**
     * @return the statudId
     */
    public int getStatusId() {
        return statusId;
    }

    /**
     * @param statudId the statudId to set
     */
    public void setStatusId(int statusId) {
        this.statusId = statusId;
    }


    public List<DeliveryOrderEntity> getChildDeliveryOrders() {
        return childDeliveryOrders;
    }

    public void setChildDeliveryOrders(List<DeliveryOrderEntity> childDeliveryOrders) {
        this.childDeliveryOrders = childDeliveryOrders;
    }



    /**
     * @return the cashInAdvance
     */
    public boolean isCashInAdvance() {
        return cashInAdvance;
    }

    /**
     * @param cashInAdvance the cashInAdvance to set
     */
    public void setCashInAdvance(boolean cashInAdvance) {
        this.cashInAdvance = cashInAdvance;
    }

//    public List<ProductBatchRecordEntity> getProductBatchRecords() {
//        return productBatchRecords;
//    }
//
//    public void setProductBatchRecords(List<ProductBatchRecordEntity> productBatchRecords) {
//        this.productBatchRecords = productBatchRecords;
//    }
 
}
